<?php

function custom_login() {
    if (isset($_SESSION['school_id'])) {
        echo <<<HERE
      <div id="right-content"><!--LEFT CONTENT STARTS-->

<!-----------BOX 1 STARTS----------->

<div class="right-top"><!--LEFT CONTENT BOX TOP-->
</div><!--LEFT CONTENT BOX TOP ENDS-->

<div class="right-middle"><!--LEFT CONTENT BOX MIDDLE-->
<div id="login-inner">
HERE;
        echo "<h3>Hi " . $_SESSION['contact_salutation']." ".$_SESSION['user_name'] . ". Welcome back!<br><br>";
        echo "<a href = '../../include/doLogout.php'>Logout</a></h3>";

        echo <<<HERE
        <input type=button value="&nbsp" class="view-program" onclick='window.location="../../school/program/viewProgram.php"'>
        <input type=button value="&nbsp" class="request-event" onclick='window.location="../../school/event/request_event_1.php"'>
        <input type=button value="&nbsp" class="representative-event" onclick='window.location="../../school/event/viewRepresentativeEvent.php"'>          
        <input type=button value="&nbsp" class="representative-detail" onclick='window.location="../../school/representative/representativeDetail.php"'>  
        <input type=button value="&nbsp" class="school-details" onclick='window.location="../../school/school_detail/schoolDetail.php"'>
       
       
</div>
      <div class="clear"></div>

</div><!--LEFT CONTENT BOX MIDDLE ENDS-->

<div class="right-bottom"><!--LEFT CONTENT BOX BOTTOM-->
</div><!--LEFT CONTENT BOX BOTTOM ENDS-->
</div><!--LEFT CONTENT ENDS-->

HERE;
    } else if (isset($_SESSION['volunteer_id'])) {
        echo <<<HERE
      <div id="right-content"><!--LEFT CONTENT STARTS-->

<!-----------BOX 1 STARTS----------->

<div class="right-top"><!--LEFT CONTENT BOX TOP-->
</div><!--LEFT CONTENT BOX TOP ENDS-->

<div class="right-middle"><!--LEFT CONTENT BOX MIDDLE-->
<div id="login-inner">
HERE;
        echo "<h3>Hi " . $_SESSION['volunteer_salutation']." ". $_SESSION['user_name']." ". $_SESSION['user_name2'] . ". Welcome back!<br><br>";
        echo "<a href = '../../include/doLogout.php'>Logout</a></h3>";

        echo <<<HERE
        <input type=button value="&nbsp" class="trainer-request" onclick='window.location="../../volunteer/event/volunteerRequestList.php"'>
        <input type=button value="&nbsp" class="view-all-event" onclick='window.location="../../volunteer/event/viewAllEvent.php"'>
        <input type=button value="&nbsp" class="volunteered-event" onclick='window.location="../../volunteer/event/viewVolunteerEvent.php"'>
        <input type=button value="&nbsp" class="volunteer-details" onclick='window.location="../../volunteer/volunteer_detail/volunteerDetail.php"'>

</div>
      <div class="clear"></div>

</div><!--LEFT CONTENT BOX MIDDLE ENDS-->

<div class="right-bottom"><!--LEFT CONTENT BOX BOTTOM-->
</div><!--LEFT CONTENT BOX BOTTOM ENDS-->
</div><!--LEFT CONTENT ENDS-->

HERE;
    } else {
        echo <<<HERE
   <div id="right-content"><!--LEFT CONTENT STARTS-->

<!-----------BOX 1 STARTS----------->

<div class="right-top"><!--LEFT CONTENT BOX TOP-->
</div><!--LEFT CONTENT BOX TOP ENDS-->

<div class="right-middle"><!--LEFT CONTENT BOX MIDDLE-->
<div id="login-inner">
HERE;
        $mes = "";
        if (isset($_SESSION['message'])) {
            $mes = $_SESSION['message'];
            echo "<h3>" . $mes . "</h3><br/>";
            $_SESSION['message'] = "";
        }
        $mes = "";

        if (isset($_COOKIE['username']) && isset($_COOKIE['password'])) {
            $user = $_COOKIE['username'];
            $pass = $_COOKIE['password'];
            echo <<<HERE
        <table border="0" cellpadding="0" cellspacing="0">
   <form action="../../include/dologin.php" class="mxform" id="form" method="post">
		<tr>
			<th>Email</th>
			<td><input type="text"  class="login-inp" name='user' value=$user /></td>
		</tr>
		<tr>
			<th>Password</th>
			<td><input type="password" value=$pass class="login-inp" name='password' /></td>
		</tr>
                <tr>
                        <th>I want to login as:</th>
                        <td><select id="role" name="role">
                            <option value="school">School</option>
                            <option value="volunteer">Volunteer</option></select>
                        </td>
                </tr>
		<tr>
			<th></th>
			<td valign="top"><input type="checkbox" class="checkbox-size" id="login-check" name="rememberme"/>Remember me</td>
		</tr>
                <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                        <th></th>
			<td><input type="submit" class="submit-login" value="&nbsp"/></td>
		</tr>
                </table>
                <center><h3><a href='../../school/registration/representativeRegistration.php'>Register as School Representative</a></h3></center>
                <center><h3><a href='../../volunteer/registration/volunteerRegistration.php'>Register as Volunteer</a></h3></center>
        </form>
      </table>
HERE;
        } else {
            echo <<<HERE
        <table border="0" cellpadding="0" cellspacing="0">
   <form action="../../include/dologin.php" class="mxform" id="form" method="post">
		<tr>
			<th>Email</th>
			<td><input type="text" class="login-inp" name='user'/></td>
		</tr>
		<tr>
			<th>Password</th>
			<td><input type="password" class="login-inp" name='password'" /></td>
		</tr>
                <tr>
                        <th>I want to login as:</th>
                        <td><select id="role" name="role">
                            <option value="school">School</option>
                            <option value="volunteer">Volunteer</option></select>
                        </td>
                </tr>
		<tr>
			<th></th>
			<td valign="top"><input type="checkbox" class="checkbox-size" id="login-check" name="rememberme"/>Remember me</td>
		</tr>
                <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                        <th></th>
			<td><input type="submit" class="submit-login"  VALUE = "&nbsp"/></td>
		</tr>
                </table>
                <center><h3><a href='../../school/registration/representativeRegistration.php'>Register as School Representative</a></h3></center>
                <center><h3><a href='../../volunteer/registration/volunteerRegistration.php'>Register as Volunteer</a></h3></center>
        </form>
      </table>
HERE;
        }
        echo <<<HERE
      </div>
      <div class="clear"></div>
	<a href="" class="forgot-pwd">Forgot Password?</a>

</div><!--LEFT CONTENT BOX MIDDLE ENDS-->

<div class="right-bottom"><!--LEFT CONTENT BOX BOTTOM-->
</div><!--LEFT CONTENT BOX BOTTOM ENDS-->
</div><!--LEFT CONTENT ENDS-->


<!--  start forgotbox ................................................................................... -->
	<div id="forgotbox">
        <div class="right-top"><!--LEFT CONTENT BOX TOP-->
        </div>
        <div class="right-middle"><!--LEFT CONTENT BOX MIDDLE-->
<div id="forgotbox-text">Please send us your email and we'll reset your password.</div>
		<!--  start forgot-inner -->
		<div id="forgot-inner">
                <form name="forgetPass" method="post" action="../../include/home/forgetPass.php">
		<table border="0" cellpadding="0" cellspacing="0">
		<tr>
			<th>Email:</th>
			<td><input type="text" value="" name='email' class="login-inp" /></td>
		</tr>
                <tr>
                        <th>I am:</th>
                        <td><select id="role" name="role">
                            <option value="school">School</option>
                            <option value="volunteer">Volunteer</option></select>
                        </td>
                </tr>
		<tr>
			<th> </th>
			<td><input type="submit" value="" class="form-submit" value="&nbsp" /></td>
		</tr>
		</table>
                </form>
		</div>
		<!--  end forgot-inner -->
		<div class="clear"></div>
		<a href="" class="back-login">Back to login</a>
        </div><!--FORGOTBOX MIDDLE ENDS-->

        <div class="right-bottom"><!--FORGOT BOX BOTTOM-->
        </div>

	</div>
	<!--  end forgotbox -->
HERE;
    }
}

function calculateEndTime($startTime, $duratioN) {
    $starttime = $startTime;
    $duration = $duratioN;
    $start_array = explode(":", $starttime);
    $add_array = explode(":", $duration);

    $hour1 = $start_array[0];
    $min1 = $start_array[1];

    $houradd = intval($add_array[0]);
    $minadd = intval($add_array[1]);

    $newmin = intval(($min1 + $minadd) % 60);
    $newhour = ($hour1 + $houradd + intval(($min1 + $minadd) / 60));
    if ($newmin >= 10) {
        $end = strval($newhour) . ":" . strval($newmin);
    } else {
        $end = strval($newhour) . ":0" . strval($newmin);
    }return



            $end;
}

?>
